package com.cxg.fairy.ec.detail;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cxg.fairy.util.log.LatteLogger;

import java.util.ArrayList;

/**
 * Created by CFairy
 */

public class TabPagerAdapter extends FragmentStatePagerAdapter {

    private final ArrayList<String> TAB_TITLES = new ArrayList<>();
    private int skuId = 0;

    public TabPagerAdapter(FragmentManager fm, JSONObject data) {
        super(fm);
        skuId = data.getInteger("id");
        TAB_TITLES.add("商品");
        TAB_TITLES.add("详情");
        TAB_TITLES.add("评价");
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return GoodsDetailDelegate.create(skuId);
        } else if (position == 1) {
            return PicStandardTabDelegate.create(skuId);
        } else if (position == 2) {
            return CommentTabDelegate.create(skuId);
        }
        return null;
    }

    @Override
    public int getCount() {
        return TAB_TITLES.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TAB_TITLES.get(position);
    }
}
